#include <cocos2d.h>
#include "cocos-ext.h"
#include "Monkey.h"
#include "Tree.h"
#include "SimpleAudioEngine.h"
#include "Config.h"
#include "Cloud.h"
#include "Component/CollisionTree.h"
#include "Component/MoveDown.h"
#include "HelloWorldScene.h"

USING_NS_CC;
USING_NS_CC_EXT;
/**
	Khoi tao doi tuong tree (CCSprite)
	mIsChoose = false -> voi nghia cay chua duoc chon
*/

Tree::Tree(Monkey *monkey,Cloud* cloud)
{
	CCSize visibleSize = CCDirector::sharedDirector()->getVisibleSize();

    CCPoint origin = CCDirector::sharedDirector()->getVisibleOrigin();

	mSize = CCDirector::sharedDirector()->getWinSize();

	CCSprite* tre = CCSprite::create("bamboofooter.png");

	addChild(tre, kZorderTree);
	mSprite = tre;

	fSetIsChoose(true);
	initTree = 1;
	mTreeSize = tre->getContentSize();

    mIsChoose = true;

	flagMoving = 1;

	this->mMonkey = monkey;

	this->mCloud = cloud;

	// Add Boa to Tree
	//fAddBoa(ccp(0,randomY()));

	addComponent(new MoveDown(mMonkey));
}

int Tree::randomY()
{
	srand( time(NULL)*500);
	int pPos = CCRANDOM_0_1() * 200;
	return pPos;
}

void Tree::fAddBoa(CCPoint p)
{
	Boa *boa = new Boa(p);
	boa->setPosition(p);
	this->addChild(boa,3);
}


